{# Form macros. Native inputs with ``name`` attributes, so every form posts or re-queries through htmx without client-side state. {% from "components/macros/form.html" import field, text_input, select, date_input, primary_button %} #} {%- set _primary_button_classes -%} text-sm text-aegis-text border border-aegis-teal bg-aegis-teal/10 rounded px-4 py-2.5 hover:bg-aegis-teal/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center justify-center gap-2 {%- endset -%} {# Inline primary button (no loading spinner). Defaults to ``type="button"`` so it doesn't accidentally submit a form it's nested inside — pass ``type="submit"`` explicitly when you want submit semantics. ``attrs`` lets the caller pass arbitrary attributes (Alpine ``@click``, ``:disabled``, ``aria-*``) without bloating the macro signature. #} {% macro primary_button(label, type="button", attrs="") %} {% endmacro %} {# Primary submit button with an inline loading spinner. Parent scope must expose ``loading`` (bool) — typically flipped by ``@submit="loading = true"`` on the form. The button disables itself while loading so a double-click can't double-submit. #} {% macro submit_button(idle_label, loading_label) %} {% endmacro %} {# Shared input styling; every control below uses it so the bar reads as one. #} {%- set _control_classes -%} bg-aegis-bg border border-aegis-border rounded px-2.5 py-1.5 text-sm text-aegis-text placeholder:text-aegis-muted/50 focus:border-aegis-teal focus:outline-none transition-colors {%- endset -%} {# A native select. ``options`` are objects or dicts with ``id`` and ``name``; ``blank`` is the "no filter" label (``None`` for no blank choice); ``selected`` the current id. ``label`` wraps it inline for a filter bar; ``block`` lays it out full-width inside a ``field()``. #} {% macro select(name, options, selected=None, blank="All", label=None, block=False) %} {% if label %}{% endif %} {% endmacro %} {% macro date_input(name, value=None, label=None, block=False) %} {% if label %}{% endif %} {% endmacro %} {% macro checkbox(name, checked=False, label=None) %} {% endmacro %} {% macro search_input(name, value=None, placeholder="Search") %} {% endmacro %} {# A labelled field. The control comes via {% call %}; ``error`` renders under it (pattern 1's 422 re-render passes field errors here). #} {% macro field(label, error=None) %}
{{ error }}
{% endif %}